package com.example.question3.controller;

import com.example.question3.client.CoffeeClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/coffee")
public class CoffeeController {
    @Autowired
    CoffeeClient coffeeClient;
    //    通过restTemplate方式访问
    @GetMapping("/by-rest-template/{id}")
    public Object getCoffee(@PathVariable("id")Long id){
        return coffeeClient.getCoffee(id);
    }

    @GetMapping("/by-web-client/{id}")
    Object getCoffeeByWebClient(@PathVariable("id")Long id) throws InterruptedException {
        return coffeeClient.getCoffeeByWebClient(id);
    }
}
